package edu.thu.studio.ormdesigner.common;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;

public abstract class ValidatableTabWrapper extends Composite {
    
    public static final int MARGIN_TAB = 10;
    
    protected TabItem tabItem;
    
    protected AbstractTabbedDialog dialog;
    
    public ValidatableTabWrapper(AbstractTabbedDialog dialog, TabFolder parent, String title) {
        
        super(parent, SWT.NONE);
        
        this.dialog = dialog;
        
        this.tabItem = new TabItem(parent, SWT.NONE);
        this.tabItem.setText(title);
        
        this.tabItem.setControl(this);
    }
    
    abstract public void validatePage() throws InputException;
    
    public final void init() {
        GridLayout layout = new GridLayout();
        this.initLayout(layout);
        this.setLayout(layout);
        
        this.initComposite();
        this.addListener();
        this.setData();
    }
    
    protected void initLayout(GridLayout layout) {
        layout.marginTop = layout.marginLeft = layout.marginRight = layout.marginBottom = MARGIN_TAB;
    }
    
    public void reset() {
    }
    
    public void restruct() {
    }
    
    abstract protected void initComposite();
    
    protected void addListener() {
    }
    
    protected void setData() {
    }
    
    abstract public void perfomeOK();
    
    abstract public void setInitFocus();
    
}
